<?php
	session_start();
	$username=$_POST['username'];
	$password=$_POST['password'];
	include("connect.php");
	if($username && $password)
	{
		$queryget1=mysql_query("SELECT * FROM admin WHERE username='$username' AND password='$password'");
		$numrows1=mysql_num_rows($queryget1);
		if($numrows1 !=0)
		{
			$_SESSION['username']=$username;
			echo "<meta http-equiv=\"refresh\" content=\"1;url=http://localhost/my_project/Software_Engineering%20Project/main/wellness/Login/login_admin.php\">";
		}
		else 
		{
			$queryget2=mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
			$numrows2=mysql_num_rows($queryget2);
			if ($numrows2 !=0 )
			{
				$arraytemp=array();
				$queryget3=mysql_query("SELECT * FROM userrole WHERE username='$username'");
				//$fetch3=mysql_fetch_assoc($queryget3);
				while($row=mysql_fetch_assoc($queryget3))
				{
					//array_push($arraytemp,$row["gamename"]);
					$arraytemp[$row["gamename"]]=$row["role"];
				}
				//$test="test";
				$_SESSION['username']=$username;
				$serialized = rawurlencode(serialize($arraytemp));
				echo '<meta http-equiv="refresh" content="1;url=http://localhost/my_project/Software_Engineering%20Project/main/wellness/select_role/select_role_page.php?rolearray='.$serialized.'">';
				//print_r($arraytemp);
				//echo '<td><a href="http://localhost/db_project/main/login/game_list_member/game_properties_member/game_properties_member_page.php?link='.$row["id"].'">'.$row["name"].'</a></td>';
				
				
			}
			else
			{
				echo "you are not user";
			}
			
				
		}
		
	}
?>